package com.github.cossbow.nsq.util;

import java.util.Collection;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.ToIntFunction;
import java.util.stream.Stream;

final
public class LambdaUtil {
    private LambdaUtil() {
    }

    //

    public static IntFunction<String[]> stringArray() {
        return String[]::new;
    }

    public static IntFunction<Long[]> longArray() {
        return Long[]::new;
    }

    public static IntFunction<Integer[]> integerArray() {
        return Integer[]::new;
    }

    public static <T, C extends Collection<T>> Function<C, Stream<T>> collectionStream() {
        return Collection::stream;
    }

    //

    //

    public static <T, R> Function<T, R> just(R r) {
        return (t) -> r;
    }

    static final Function<?, Void> FUN_EMPTY = just(null);

    @SuppressWarnings("unchecked")
    public static <T> Function<T, Void> empty() {
        return (Function<T, Void>) FUN_EMPTY;
    }

    public static <T> Consumer<T> doNothing() {
        return t -> {
        };
    }

}
